package cn.lingyangwl.framework.config;

import cn.lingyangwl.framework.core.response.format.ResponseCode;
import cn.lingyangwl.framework.core.response.format.ResponseFormat;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shenguangyang
 */
@Configuration
public class MyResponseFormatConfig {
    @Bean
    public ResponseFormat responseFormat() {
        ResponseFormat format = new ResponseFormat(ResponseCode.builder().fail(-1).success(1).build());
        format.setMessageName("errMsg");
        format.setDataName("data");
        format.setCodeName("errMsg");
        /*
         * 内部请求中 - 请求头key
         * 如果请求头中携带指定的 key - value, 则响应结构为 {@link Resp} 对象的响应结构,
         * 否则为用户自定义的响应结构,
         */
//        format.setInnerHeaderKey("from");
//        format.setInnerHeaderValue("inner");
        return format;
    }
}
